package org.esk.dablog.service;

import org.esk.dablog.model.Entry;
import org.esk.dablog.model.Author;
import org.esk.dablog.model.Comment;
import org.esk.dablog.model.forum.ForumTopicEntry;
import org.esk.dablog.model.forum.ForumPostEntry;
import org.esk.dablog.model.entries.Ride;
import org.esk.dablog.exceptions.BusinessException;

import java.util.List;
import java.util.Calendar;
import java.util.Date;

/**
 * This class
 * User: jc
 * Date: 22.11.2006
 * Time: 12:37:00
 * $Id:$
 */
public interface EntryManager {

    /**
     * adds new entry to the list
     * @param e
     * @return
     */
    long addEntry(Entry e) throws BusinessException;

    /**
     * returns list of entries 
     * @return
     */
    List<Entry> listEntries();

    /**
     * returns list of last entries 
     * @return
     */
    List<Entry> listEntries(Class<? extends Entry> clazz, int count);

    /**
     * returns list of entries by month - usually 30 or 31 entries
     * depending on month length
     * @param calendar
     * @return
     */
    List<Integer> listMonthCalendar(Class<? extends Entry> clazz, Calendar calendar);

    /**
     * returns list of entries by that date (time 00:00:00-23:59:59)
     * @param calendarDate
     * @return
     */
    List listEntriesByDate(Class<? extends Entry> clazz, Date calendarDate);

    /**
     * Returns entry by its id
     * @param entryId
     * @return
     */
    Entry getEntry(Class<? extends Entry> clazz, long entryId) throws BusinessException;

    /**
     * Updates the Entry instance
     * @param entry
     */
    void updateEntry(Entry entry);

    /**
     * adds author to the ride
     * @param ride
     * @param author
     */
    void addAuthorToRide(Ride ride, Author author);

    /**
     * Removes Author from the ride
     * @param ride
     * @param author
     */
    void removeAuthorFromRide(Ride ride, Author author);

    /**
     * Returns list of entries of specified class
     * @return
     * @param clazz
     */
    List listEntries(Class<? extends Entry> clazz);

    /**
     * Returns list of entries of specified classes, paginated version
     * @param entryClasses
     * @return
     */
    List<Entry> listEntries(List<Class<? extends Entry>> entryClasses, int start, int count);

    /**
     * Saves comment in the database
     * @param c
     */
    void saveComment(Comment c);

    /**
     * Loads comment from the database
     * @param commentId
     * @return
     */
    Comment getComment(long commentId);

    /**
     * returns paginated list of Entry comments
     * @param entry
     * @param start
     * @param count
     * @return
     */
    List<Comment> listComments(Entry entry, int start, int count);

    /**
     * returns list of visible (state < 1000) entries
     * @param aClass
     * @param i
     * @return
     */
    List listVisibleEntries(Class<? extends Entry> aClass, int i);

    /**
     * deletes entry from the database
     * @param entryId
     */
    void deleteEntry(long entryId);
}
